#ifndef __ring_buffer__H
#define __ring_buffer__H


#ifdef __cplusplus
extern "C" {
#endif

#include "FreeRTOS.h"
#include "task.h"
#include "main.h"
#include "cmsis_os.h"



#define rb_malloc         pvPortMalloc
#define rb_free           vPortFree


typedef int ringbuffer_type;
typedef unsigned char ringbuffer_data_type;


typedef struct {
    ringbuffer_type len;
    ringbuffer_type out;
    ringbuffer_type in;
    ringbuffer_data_type *dat;
} __ring_buffer, *rb_p;


//typedef __ring_buffer *rb_p;

ringbuffer_type ringbuffer_init(rb_p rb, ringbuffer_data_type *buf, ringbuffer_type len);

ringbuffer_type ringbuffer_push_char(rb_p rb, ringbuffer_data_type *buf);

ringbuffer_type ringbuffer_pop_char(rb_p rb, ringbuffer_data_type *buf);

ringbuffer_type ringbuffer_push_chars(rb_p rb, ringbuffer_data_type *buf, ringbuffer_type len);

rb_p     ringbuffer_create(int size);
void     ringbuffer_destory(rb_p rb);


#ifdef __cplusplus
 }
#endif

#endif

